/*
 * Order class is responsible for:
 * looking up CashRegister info collecting Employee info,
 * array of lineItems calculating sale total amount 
 * displaying sale info
 */
package Model;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

public class Order {
    private DecimalFormat fprice = new DecimalFormat("TL#,##0.00");
    private ArrayList<OrderLineItem> orderLineItemList;
    private Date date ;
    private Calendar calendar;
    private String dformat = "MM/dd/yyyy  hh:mm a";
    private SimpleDateFormat sdf;
    private Employee emp;

       
    //constructor
    public Order(Employee emp){
        orderLineItemList = new ArrayList<OrderLineItem>();
        date = new Date();
        calendar = Calendar.getInstance();
        sdf = new SimpleDateFormat(dformat);
        setEmp(emp);
    }
    public Order(){      
        orderLineItemList = new ArrayList<OrderLineItem>();
        date = new Date();
        calendar = Calendar.getInstance();
        sdf = new SimpleDateFormat(dformat);
    }


    //getter setter
    public ArrayList<OrderLineItem> getOrderLineItemList() {
        return orderLineItemList;
    }

    public void setOrderLineItemList(ArrayList<OrderLineItem> orderLineItemList) {
        this.orderLineItemList = orderLineItemList;
    }

    public Date getDate() {
        return date;
    }

    public Employee getEmp() {
        return emp;
    }

    public void setEmp(Employee emp) {
        this.emp = emp;
    }
        
    public void setDate(Date date) {
        this.date = date;
    }

    public Calendar getCalendar() {
        return calendar;
    }

    public void setCalendar(Calendar calendar) {
        this.calendar = calendar;
    }

    public SimpleDateFormat getSdf() {
        return sdf;
    }

    public void setSdf(SimpleDateFormat sdf) {
        this.sdf = sdf;
    }

    //getTotal:sum of all line item prices
     public double getTotal() {
	double saleTotal = 0;
	for (OrderLineItem oli : orderLineItemList) {
	    saleTotal += oli.getSubTotal();
	}
	return saleTotal;
    }
    
     //add orderLineItem to the order
    public void makeLineItem(OrderLineItem orderLineItem){
        orderLineItemList.add(orderLineItem);
    }
    //remove orderLineItem from order
    public void removeLineItem(OrderLineItem orderLineItem){
        orderLineItemList.remove(orderLineItem);
    }






}
